class CategoriesController < ApplicationController
    include AuthenticatedSystemBrowse
    
    def show
        @category = PostCategory.find(params[:id])
        @posts = CommonPost.paginate_by_post_category_id @category, :include => [:user, :post_category, {:community => :district} ], :order => "replied_at DESC", :page => params[:page]
        if @category.parent_id == 0
            sub_cats = @category.children
            @posts = CommonPost.paginate :conditions => ["post_category_id in (#{sub_cats.collect{|n| n.id}.join(',')})"], :include => [:user, :post_category, {:community => :district} ], :page => params[:page]
        else
            @posts = CommonPost.paginate_by_post_category_id @category, :include => [:user, :post_category, {:community => :district} ], :order => "replied_at DESC", :page => params[:page]
        end
    end
end
